import React, { Component } from 'react';
import PropTypes from 'prop-types';
import classnames from 'classnames';
import { Icon } from 'antd-mobile'

// ========================================
/**
 * 	<LoanResultPage
	 icon = "check-circle-o"				// icon值，可不填写
	 title = "提交成功"						// 必填
	 content = { ... }						// 主要文本内容，此处可以写元素标签，可不填写
     btns = {['借款凭证', '查看还款计划']}	// 底部按钮数组，可不填写
     btns = {[{'借款凭证'}, '查看还款计划']}	// 底部按钮数组，可不填写
     btns={
     	[
        	{'title':'借款凭证','path':'/HmdMain/LoanVoucher'},
        	{'title':'还款计划','path':'/HmdMain/RepaymentSchedule'}
    	]
     }
	 />
 * */
// ========================================
import './index.less';
class LoanResultPage extends Component {
	static contextTypes = {
	    router: PropTypes.object.isRequired
  	}
	jumpToPage = (path) => {
		
		if(path){
			this.context.router.push({
		    	pathname: path
		    })
		}
		
	}
	
    render() {
        let {icon, title, content, btns} = this.props;
        // leftContentTitle = leftContentTitle ? leftContentTitle : "@back";
		// 底部按钮组
		let btnArr = [];
		if (btns && (btns.length > 0)) {
            btnArr.unshift(
                btns.map((item, index, arr) => {
                    if (index === arr.length - 1) {
                        return (
                            <div style={{display: 'inline-block'}}>
                                &nbsp;&nbsp;<a href="javascript: void(0);" onClick={this.jumpToPage.bind(this, item['path'])}>{item['title']}</a>
                            </div>
                        )
                    } else {
                        return (
                            <div style={{display: 'inline-block'}}>
                                &nbsp;&nbsp;<a href="javascript: void(0);" onClick={this.jumpToPage.bind(this, item['path'])}> {item['title']}</a> &nbsp;&nbsp;|
                            </div>
                        )
                    }
                })
			)
		}
        return (
            <div id="result">
                <div className="result-title">
								{
									icon ? <div className="result-icon"><Icon type={icon} /></div> : ''
								}
                    <div className="result-title">
                        {title}
                    </div>
                </div>
                <div className="result-content">
                    {
                        content ? content : ''
					}
                </div>
                {
                    (btns && (btns.length > 0)) ?
                        <div className="result-a">
							{btnArr}
                        </div>
                        : ''
                }
				{

				}
            </div>
        );
    }
}

/*Progress.propTypes = {
  progress: PropTypes.number
};*/
// ========================================
export default LoanResultPage;